using System;
using System.Collections.Generic;

namespace Launcher
{
    public sealed class AssemblyLoaderParameters
    {
        private string _assemblyLoadContextName = string.Empty;
        private string _assemblyDirectory = string.Empty;
        private string _entryAssemblyFile = string.Empty;
        private string _entryType = string.Empty;
        private string _threadApartmentState = string.Empty;
        private string _commandLineArgs = string.Empty;

        public AssemblyLoaderParameters(
            string assemblyLoadContextName,
            string assemblyDirectory,
            string entryAssemblyFile,
            string entryType,
            string threadApartmentState,
            string commandLineArgs)
        {
            // 通过属性设置器确保所有参数都经过验证
            AssemblyLoadContextName = assemblyLoadContextName;
            AssemblyDirectory = assemblyDirectory;
            EntryAssemblyFile = entryAssemblyFile;
            EntryType = entryType;
            ThreadApartmentState = threadApartmentState;
            CommandLineArgs = commandLineArgs;
        }

        public string CommandLineArgs
        {
            get => _commandLineArgs;
            set => _commandLineArgs = value ?? string.Empty;
        }

        public string ThreadApartmentState
        {
            get => _threadApartmentState;
            set => _threadApartmentState = AssemblyLoaderParametersValidator.ValidateThreadApartmentState(value);
        }

        public string AssemblyDirectory
        {
            get => _assemblyDirectory;
            set => _assemblyDirectory = AssemblyLoaderParametersValidator.ValidateAssemblyDirectory(value);
        }

        public string EntryAssemblyFile
        {
            get => _entryAssemblyFile;
            set => _entryAssemblyFile = AssemblyLoaderParametersValidator.ValidateEntryAssemblyFile(value, _assemblyDirectory);
        }

        public string EntryType
        {
            get => _entryType;
            set
            {
                AssemblyLoaderParametersValidator.ValidateEntryType(value);
                _entryType = value;
            }
        }

        public string AssemblyLoadContextName
        {
            get => _assemblyLoadContextName;
            set
            {
                AssemblyLoaderParametersValidator.ValidateAssemblyLoadContextName(value);
                _assemblyLoadContextName = value;
            }
        }
    }
}